package com.scaffolding.sophia.auth.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 〈自定义无加密密码验证〉
 *
 * @author yihur
 */
@Slf4j
public class NoEncryptPasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence charSequence) {
        log.info("密码字符序列：{}", charSequence);
        return (String) charSequence;
    }

    /**
     * 该方法会对比两种密码,一种是clentid密码一种是用户密码,如果要完全屏蔽密码校验需要关闭两个地方
     * @param charSequence
     * @param s
     * @return
     */
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        log.info("匹配字符序列：{},传入的字符串:{}", charSequence, s);
        return s.equals((String) charSequence);
        //return true;
    }
}
